package com.xj.spring.framework.beans.suppoort;

import com.xj.spring.framework.beans.config.MyBeanDefinition;
import com.xj.spring.framework.core.MyBeanFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xujiang
 * @date 2021/5/6 23:08
 **/
public class MyDefaultListableBeanFactory implements MyBeanFactory {

    public Map<String, MyBeanDefinition> beanDefinitionMap = new HashMap<String, MyBeanDefinition>();
    @Override
    public Object getBean(Class beanClass) {
        return null;
    }

    @Override
    public Object getBean(String beanName) {
        return null;
    }

    public void doRegistBeanDefinition(List<MyBeanDefinition> beanDefinitions) throws Exception {
        for (MyBeanDefinition beanDefinition : beanDefinitions) {
            if (this.beanDefinitionMap.containsKey(beanDefinition.getFactoryBeanName())) {
                throw new Exception("The " + beanDefinition.getFactoryBeanName() + " is exists!!!");
            }
            this.beanDefinitionMap.put(beanDefinition.getFactoryBeanName(), beanDefinition);
        }
    }
}
